var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  ArmyEquipmentDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        t.btn_army_unload.on(Laya.Event.CLICK, t, t.onDidClickSureUnloadAction),
        (t.list_armyEquipment.selectEnable = !0),
        (t.list_armyEquipment.vScrollBarSkin = ""),
        (t.list_armyEquipment.renderHandler = new Handler(
          t,
          t.updateItemRenderHandler
        )),
        t.list_armyEquipment.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickSureAdornAction
        ),
        WebSocketService.addListener({
          caller: t,
          code: 1056,
          method: t.onLoadMyEquipmentDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1062,
          method: t.onLoadEquDetailDataFn,
        }),
        WebSocketService.addListener(
          { caller: t, code: 1137, method: t.onLoadEWearEquimentDataFn },
          !0
        ),
        WebSocketService.addListener({
          caller: t,
          code: 1136,
          method: t.onLoadUnloadEquimentDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 1108,
          method: t.onLoadMyEquipmentDataFn,
        }),
        WebSocketService.addListener({
          caller: t,
          code: 4482,
          method: t.onLoadEquiOperationDataFn,
        }),
        t.label_equip_forge.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickEquipForgeAction
        ),
        WebSocketService.addListener({
          caller: t,
          code: 5288,
          method: t.onLoadEquipmentXiLianData,
        }),
        t
      );
    }
    return (
      __extends(t, e),
      (t.prototype.initData = function () {
        (this.eqObj = {}),
          (this.label_xilian_tips1.visible = !1),
          (this.label_equip_forge.visible = !1);
      }),
      (t.showEquipmentView = function (e) {
        null == this.armyEquipmentV &&
          ((this.armyEquipmentV = new t()),
          (this.armyEquipmentV.zOrder = 1001)),
          this.armyEquipmentV.popup(),
          this.armyEquipmentV.initData(),
          (this.armyEquipmentV.eqObj = e),
          e.eq_id
            ? (WebSocketService.send({ c: 1062, d: { id: e.eq_id } }),
              (this.armyEquipmentV.label_arny_equipment_tips.visible = !0))
            : (this.armyEquipmentV.cleanEquipmentDetailData(),
              (this.armyEquipmentV.label_arny_equipment_tips.visible = !1)),
          "AXSuboardinateDetailView" == e.preClass
            ? WebSocketService.send({ c: 1108, d: { pageNum: 0 } })
            : (WebSocketService.send({
                c: 1056,
                d: { type: e.eq_type, pageNum: 0 },
              }),
              (this.armyEquipmentV.label_arny_equipment_tips.visible = !1));
      }),
      (t.prototype.cleanEquipmentDetailData = function () {
        var e = Utils.transform(this.eqObj.eq_type, "equipType");
        (this.label_army_title.text = e + " - 未穿戴"),
          (this.label_armyItem1.text = "请先去选择装备佩戴"),
          (this.label_armyItem2.text = ""),
          (this.btn_army_unload.disabled = !0),
          (this.image_armyEqui_icon.skin = ""),
          (this.label_arny_equipment_tips.visible = !1);
      }),
      (t.prototype.onLoadMyEquipmentDataFn = function (e) {
        if (0 == e.code) {
          var t = [],
            i = [];
          if (1108 == e.act_id) {
            i = e.data;
            for (var a = void 0, n = 0; n < i.length; n++) {
              (o = i[n]).id != this.eqObj.eq_id &&
                ((a = { adornName: { text: o.name + o.stoneStr }, id: o.id }),
                t.push(a));
            }
          } else if (1056 == e.act_id) {
            i = e.list;
            for (var a = void 0, n = 0; n < i.length; n++) {
              var o = i[n];
              o.id != this.eqObj.eq_id &&
                ((a = {
                  adornName: { text: "Lv" + o.level + o.name },
                  id: o.id,
                }),
                t.push(a));
            }
          }
          this.list_armyEquipment.dataSource = t;
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onLoadEquDetailDataFn = function (e) {
        if (0 == e.code) {
          this.btn_army_unload.disabled = !1;
          for (
            var t = e.data, i = "", a = "", n = "", o = "", s = void 0, r = 0;
            r < t.length;
            r++
          ) {
            var l = t[r].k,
              d = t[r].v;
            if ("名称:" != l)
              if ("等级:" != l)
                if ("图片:" != l) {
                  if ("AXSuboardinateDetailView" == this.eqObj.preClass) {
                    if ("佩带条件:" == l) continue;
                    if ("是否装备:" == l) continue;
                  } else if ("是否装备:" == l) {
                    i = i + "（" + d + "）";
                    continue;
                  }
                  if ("重量:" != l)
                    if ("高阶属性:" != l)
                      if ("效果:" != l) n = n + l + d + "\n";
                      else {
                        a = a + l + d + "\n";
                        d.split(",");
                      }
                    else {
                      o = l + d;
                      (s = d.match(/\d+/g)),
                        parseInt(s) >= 10 &&
                          ((this.label_xilian_tips1.visible = !1),
                          (this.label_equip_forge.visible = !1));
                    }
                  else a = a + l + d + "\n";
                } else this.image_armyEqui_icon.skin = "arming/" + d + ".png";
              else
                (i = "Lv" + d + " " + i),
                  d,
                  d >= 11
                    ? ((this.label_xilian_tips1.visible = !0),
                      (this.label_equip_forge.visible = !0))
                    : ((this.label_xilian_tips1.visible = !1),
                      (this.label_equip_forge.visible = !1));
            else i += d;
          }
          (this.label_army_title.text = i),
            (this.label_armyItem1.text = a),
            (this.label_armyItem2.text = n),
            (this.label_armyItem3.text = o);
        }
      }),
      (t.prototype.updateItemRenderHandler = function (e, t) {
        var i = e.getChildByName("adornButton");
        "AXSuboardinateDetailView" == this.eqObj.preClass
          ? "" == this.eqObj.eq_id
            ? (i.disabled = !1)
            : (i.disabled = !0)
          : (i.disabled = !1);
      }),
      (t.prototype.onLoadEWearEquimentDataFn = function (e) {
        if (0 == e.code) {
          if (
            void 0 == this.list_armyEquipment.selectedItem ||
            null == this.list_armyEquipment.selectedItem
          )
            return void console.log("list_armyEquipment");
          var t = this.list_armyEquipment.selectedItem;
          WebSocketService.send({ c: 1062, d: { id: t.id } }),
            WebSocketService.send({
              c: 1056,
              d: { type: this.eqObj.eq_type, pageNum: 0 },
            }),
            (this.eqObj.eq_id = t.id),
            WebSocketService.send({
              c: 1056,
              d: { type: this.eqObj.eq_type, pageNum: 0 },
            }),
            WebSocketService.send({ c: 1e3, d: null }),
            "AXSuboardinateDetailView" == this.eqObj.preClass &&
              (this.label_arny_equipment_tips.visible = !0);
        } else ToastView.toastView(e.msg);
      }),
      (t.prototype.onDidMoreItemClick = function () {
        AdornEquipmentView.showEquipmentView(this.eqObj.type);
      }),
      (t.prototype.onDidClickSureUnloadAction = function () {
        if ("AXSuboardinateDetailView" == this.eqObj.preClass) {
          var e = this.eqObj;
          WebSocketService.send({
            c: 4482,
            d: { action: 2, cid: e.eq_uid, aid: e.eq_id, location: e.seat },
          }),
            (this.eqObj.eq_id = "");
        } else
          WebSocketService.send({ c: 1136, d: { type: this.eqObj.eq_type } });
      }),
      (t.prototype.onLoadUnloadEquimentDataFn = function (e) {
        0 == e.code
          ? (this.cleanEquipmentDetailData(),
            "AXSuboardinateDetailView" == this.eqObj.preClass ||
              (WebSocketService.send({
                c: 1056,
                d: { type: this.eqObj.eq_type, pageNum: 0 },
              }),
              (this.eqObj.eq_id = ""),
              WebSocketService.send({ c: 1e3, d: null })))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onDidClickSureAdornAction = function (e) {
        if ("" != e.target.name) {
          var t = this.list_armyEquipment.selectedItem;
          if ("adornButton" == e.target.name)
            if ("AXSuboardinateDetailView" == this.eqObj.preClass) {
              var i = this.eqObj.eq_uid;
              this.eqObj.eq_id = t.id;
              var a = t.id;
              WebSocketService.send({
                c: 4482,
                d: { action: 1, cid: i, aid: a, location: this.eqObj.seat },
              });
            } else WebSocketService.send({ c: 1137, d: { id: t.id } });
        }
      }),
      (t.prototype.onLoadEquiOperationDataFn = function (e) {
        if (0 == e.code) {
          var t = this.eqObj;
          "" == t.eq_id
            ? (this.cleanEquipmentDetailData(),
              WebSocketService.send({ c: 1108, d: { pageNum: 0 } }),
              (this.label_arny_equipment_tips.visible = !1))
            : (WebSocketService.send({ c: 1062, d: { id: t.eq_id } }),
              WebSocketService.send({ c: 1108, d: { pageNum: 0 } }),
              (this.label_arny_equipment_tips.visible = !0));
        }
      }),
      (t.prototype.onDidClickEquipForgeAction = function () {
        this.eqObj.eq_id &&
          "" != this.eqObj.eq_id &&
          WebSocketService.send({ c: 5288, d: { armingId: this.eqObj.eq_id } });
      }),
      (t.prototype.onLoadEquipmentXiLianData = function (e) {
        ToastView.toastView(e.msg),
          WebSocketService.send({ c: 1062, d: { id: this.eqObj.eq_id } }),
          Laya.stage.event("GameMainView", "refreshMoney"),
          Laya.stage.event("HomePageView", "refreshMoney");
      }),
      t
    );
  })(ui.UserInfoController.ArmyEquipmentDialogUI);
